<html>
<head><meta charset="utf-8"><title>Does Miri support `repr(align)`? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html">Does Miri support `repr(align)`?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172237033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237033">(Aug 01 2019 at 16:37)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span><span class="p">;</span><span class="w"></span>

<span class="cp">#[derive(Debug, Default)]</span><span class="w"></span>
<span class="cp">#[repr(align(8))]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">AlignToU64</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">T</span><span class="p">);</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="n">BYTE_LEN</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="p">[</span><span class="kt">u64</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">]</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="k">type</span> <span class="nc">Data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">AlignToU64</span><span class="o">&lt;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">BYTE_LEN</span><span class="p">]</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">example</span><span class="p">(</span><span class="n">data</span>: <span class="kp">&amp;</span><span class="nc">Data</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">head</span><span class="p">,</span><span class="w"> </span><span class="n">u64_arrays</span><span class="p">,</span><span class="w"> </span><span class="n">tail</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">data</span><span class="p">.</span><span class="mf">0.</span><span class="n">align_to</span>::<span class="o">&lt;</span><span class="p">[</span><span class="kt">u64</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">]</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">head</span><span class="p">.</span><span class="n">is_empty</span><span class="p">(),</span><span class="w"> </span><span class="s">&quot;buffer was not aligned for 64-bit numbers&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">u64_arrays</span><span class="p">.</span><span class="n">len</span><span class="p">(),</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;buffer was not long enough&quot;</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="n">tail</span><span class="p">.</span><span class="n">is_empty</span><span class="p">(),</span><span class="w"> </span><span class="s">&quot;buffer was too long&quot;</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">example</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Data</span>::<span class="n">default</span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>This code passes outside of Miri, but fails inside:</p>
<div class="codehilite"><pre><span></span>error[E0080]: Miri evaluation error: the evaluated program panicked at &#39;buffer was not aligned for 64-bit numbers&#39;, src/main.rs:13:5
  --&gt; src/main.rs:13:5
   |
13 |     assert!(head.is_empty(), &quot;buffer was not aligned for 64-bit numbers&quot;);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri evaluation error: the evaluated program panicked at &#39;buffer was not aligned for 64-bit numbers&#39;, src/main.rs:13:5
   |
</pre></div>



<a name="172237051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237051">(Aug 01 2019 at 16:38)</a>:</h4>
<p>/cc <span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="120791">@RalfJ</span></p>



<a name="172237104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237104">(Aug 01 2019 at 16:38)</a>:</h4>
<p>I see <code>repr(packed)</code> in Miri testcases, but didn't see <code>repr(align)</code>. No issues immediately popped out, either.</p>



<a name="172237618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237618">(Aug 01 2019 at 16:45)</a>:</h4>
<p>I dont think miri needs any extra handling for <code>repr(align)</code>, that just affects layout computation. but let me digest that example.</p>



<a name="172237705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237705">(Aug 01 2019 at 16:46)</a>:</h4>
<p><code>align_to</code> in Miri always puts everything into the first component</p>



<a name="172237721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237721">(Aug 01 2019 at 16:46)</a>:</h4>
<p>so Miri does support <code>align</code> but Miri also exploits the freedom that the <code>align_to</code> spec grants</p>



<a name="172237732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237732">(Aug 01 2019 at 16:46)</a>:</h4>
<p>which is to say "oh Im sorry you cannot align this"</p>



<a name="172237748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237748">(Aug 01 2019 at 16:47)</a>:</h4>
<p>...</p>



<a name="172237992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172237992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172237992">(Aug 01 2019 at 16:48)</a>:</h4>
<p>now, we could do better. and by this I mean, even considering that I am not sure we want an implementation that is equivalent to what rustc does, because that impedes our ability to find mis-aligned accesses, we could still do better.</p>



<a name="172238002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238002">(Aug 01 2019 at 16:48)</a>:</h4>
<p>I am not sure if that's enough for your example though.</p>



<a name="172238065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238065">(Aug 01 2019 at 16:49)</a>:</h4>
<p>oh and just to complete the lawyering, the <a href="https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.align_to" target="_blank" title="https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.align_to">spec says</a>:</p>
<blockquote>
<p>The method does a best effort to make the middle slice the greatest length possible for a given type and input slice, but only your algorithm's performance should depend on that, not its correctness.</p>
</blockquote>



<a name="172238073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238073">(Aug 01 2019 at 16:49)</a>:</h4>
<p>I see what you are saying, but I feel like it's veering into the camp of</p>



<a name="172238079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238079">(Aug 01 2019 at 16:49)</a>:</h4>
<p>yeah, rules lawyering</p>



<a name="172238092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238092">(Aug 01 2019 at 16:49)</a>:</h4>
<p>well the thing is these rules are useful</p>



<a name="172238179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238179">(Aug 01 2019 at 16:50)</a>:</h4>
<p>Except that the quoted rules taken to the letter effectively make the function useless.</p>



<a name="172238204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238204">(Aug 01 2019 at 16:50)</a>:</h4>
<p>"Here is a thing <strong>guaranteed</strong> by the language to be aligned" ... "oh, that's not aligned"</p>



<a name="172238206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238206">(Aug 01 2019 at 16:50)</a>:</h4>
<p>that is incorrect</p>



<a name="172238216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238216">(Aug 01 2019 at 16:50)</a>:</h4>
<p>the part in the middle is guaranteed to be aligned</p>



<a name="172238221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238221">(Aug 01 2019 at 16:50)</a>:</h4>
<p>libstd correctly uses this function to great effect</p>



<a name="172238275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238275">(Aug 01 2019 at 16:51)</a>:</h4>
<p>just because you used it wrong and without reading the spec (or ignoring it) doesnt mean it cant usefully be used correctly ;)</p>



<a name="172238344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238344">(Aug 01 2019 at 16:52)</a>:</h4>
<p>Ok, what is the appropriate function to use?</p>



<a name="172238345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238345">(Aug 01 2019 at 16:52)</a>:</h4>
<p>the typical usecase is to process the parts on the 1st and 3rd slice with a "slow path" and use an alignment-optimized "fast path" for the middle</p>



<a name="172238365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238365">(Aug 01 2019 at 16:52)</a>:</h4>
<p>memchr and memrchr do that, for example. both work fine in Miri.</p>



<a name="172238391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238391">(Aug 01 2019 at 16:52)</a>:</h4>
<p>what you are doing with this function is weird... there's no point in using it if you already know everything is aligned</p>



<a name="172238409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238409">(Aug 01 2019 at 16:53)</a>:</h4>
<p>Do I need to (as <span class="user-mention" data-user-id="124288">@oli</span> said... somewhere) use <code>ptr::align</code>and do it myself?</p>



<a name="172238411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238411">(Aug 01 2019 at 16:53)</a>:</h4>
<p>just cast your pointers</p>



<a name="172238441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238441">(Aug 01 2019 at 16:53)</a>:</h4>
<p>or check alignment</p>



<a name="172238450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238450">(Aug 01 2019 at 16:53)</a>:</h4>
<p><code>aign_to</code> is for when you want to handle any-aligned data</p>



<a name="172238467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238467">(Aug 01 2019 at 16:53)</a>:</h4>
<p>you clearly dont want to do that, sicne you are asserting the first and last component to be empty</p>



<a name="172238526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238526">(Aug 01 2019 at 16:54)</a>:</h4>
<p>Which I <strong>did</strong>, until <a href="#narrow/stream/122651-general/topic/how.20much.20should.20I.20worry.20about.20alignment.20on.20x86.3F" title="#narrow/stream/122651-general/topic/how.20much.20should.20I.20worry.20about.20alignment.20on.20x86.3F">that tanked my performance</a></p>



<a name="172238532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238532">(Aug 01 2019 at 16:54)</a>:</h4>
<p>so just do <code>assert!(data as *const _ as usize % mem::align_of::&lt;u64&gt;() == 0)</code> or so</p>



<a name="172238575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238575">(Aug 01 2019 at 16:54)</a>:</h4>
<p>I dont see how making your code more complicated by calling <code>align_to</code> will make performance better?</p>



<a name="172238620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238620">(Aug 01 2019 at 16:55)</a>:</h4>
<p>the recommendation to sue <code>align_to</code> as to use it the way it is intended to be used</p>



<a name="172238641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238641">(Aug 01 2019 at 16:55)</a>:</h4>
<p>not to shoehorn it into your existing code in ways that make little sense</p>



<a name="172238659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238659">(Aug 01 2019 at 16:56)</a>:</h4>
<p>but I also dont know anything about how to make the optimizer happy^^</p>



<a name="172238753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238753">(Aug 01 2019 at 16:57)</a>:</h4>
<p>No, I mean that my original code could operate on unaligned data, so I wanted to use <code>align_to</code>to handle it. The algorithm itself doesn't handle it well, so I'm having to rewrite that. Now I have to rewrite this as well.</p>



<a name="172238777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238777">(Aug 01 2019 at 16:57)</a>:</h4>
<p>all I can help you with is correctness and clarity, and in terms of that, I'd say it is quite clear: <code>align_to</code> is for when you dont know if your input is aligned, but it is a big slice of things that has an "aligned middle part".<br>
your case seems to be that it already has to be aligned, so you can just assert that and go on with it. (you might run into Miri limitations at some point as well but then it'll really be Miri's fault. ;)</p>



<a name="172238852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238852">(Aug 01 2019 at 16:58)</a>:</h4>
<p>IIRC you said the algorithm didnt handle unaligned "pre"-data or so?</p>



<a name="172238859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238859">(Aug 01 2019 at 16:58)</a>:</h4>
<p>I sense an XY problem somewhere near us^^</p>



<a name="172238879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238879">(Aug 01 2019 at 16:58)</a>:</h4>
<p>No</p>



<a name="172238899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238899">(Aug 01 2019 at 16:58)</a>:</h4>
<p>Basically <code>align_to</code> has zero use whatsoever in this code.</p>



<a name="172238900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238900">(Aug 01 2019 at 16:58)</a>:</h4>
<p>I dont see how "using align_to to handle it" implies "using align_to in a case where it literally makes no sense because you assume data is already aligned"</p>



<a name="172238912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238912">(Aug 01 2019 at 16:59)</a>:</h4>
<blockquote>
<p>Basically <code>align_to</code> has zero use whatsoever in this code.</p>
</blockquote>
<p>that may well be the case</p>



<a name="172238941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238941">(Aug 01 2019 at 16:59)</a>:</h4>
<p>if the algorithm cannot work with an unaligned prefix followed by an aligned central part, indeed align_to does not help</p>



<a name="172238965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238965">(Aug 01 2019 at 16:59)</a>:</h4>
<p>Originally I used <code>align_to</code> to handle unaligned data, and I wanted to reuse the same code for a buffer I <em>knew</em> to be aligned</p>



<a name="172238998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172238998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172238998">(Aug 01 2019 at 17:00)</a>:</h4>
<p>if there is some mroe context around the minimal example you gave me above, sure maybe the code makes sense</p>



<a name="172239075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239075">(Aug 01 2019 at 17:00)</a>:</h4>
<p>I dont know that context, obviously</p>



<a name="172239088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239088">(Aug 01 2019 at 17:00)</a>:</h4>
<p>Well, we've talked about it in the other thread.</p>



<a name="172239092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239092">(Aug 01 2019 at 17:00)</a>:</h4>
<p>you would have to lobby for strengthening the align_to spec then though</p>



<a name="172239104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239104">(Aug 01 2019 at 17:00)</a>:</h4>
<p>and maybe Miri should support align_to better (and certainly it has to if the spec gets strengthened)</p>



<a name="172239112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239112">(Aug 01 2019 at 17:01)</a>:</h4>
<p>This boils down to I'm stupid and can't read the documentation or implement an algorithm.</p>



<a name="172239132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239132">(Aug 01 2019 at 17:01)</a>:</h4>
<p>So I probably shouldn't be writing this code in the first place.</p>



<a name="172239143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239143">(Aug 01 2019 at 17:01)</a>:</h4>
<blockquote>
<p>Well, we've talked about it in the other thread.</p>
</blockquote>
<p>I barely remember anything from that, it's not like I was heavily involved or didnt have two dozen other Rust discussions since then^^</p>



<a name="172239164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239164">(Aug 01 2019 at 17:01)</a>:</h4>
<p>I dont think you are stupid :)<br>
and I am sorry if I came across too negative above</p>



<a name="172239181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239181">(Aug 01 2019 at 17:01)</a>:</h4>
<p>My only feedback is that Miri should put at least one thing into the aligned chunk, otherwise that code will never be exercised by Miri.</p>



<a name="172239251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239251">(Aug 01 2019 at 17:02)</a>:</h4>
<blockquote>
<p>My only feedback is that Miri should put at least one thing into the aligned chunk, otherwise that code will never be exercised by Miri.</p>
</blockquote>
<p>that is indeed a concern I had. but there's a big downside to doing that, which is that we can no longer reliably detect unaligned accesses.</p>



<a name="172239288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239288">(Aug 01 2019 at 17:03)</a>:</h4>
<p>accesses might be aligned "by chance" (because of what the allocator picked) and we could not distinguish that from properly checked aligned accesses</p>



<a name="172239319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239319">(Aug 01 2019 at 17:03)</a>:</h4>
<p>we had the thought of emitting a warning when that happens (we can detect that case) and encouraging the user to run Miri with lots of different seeds</p>



<a name="172239336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239336">(Aug 01 2019 at 17:03)</a>:</h4>
<p>but if we then make <code>align_to</code> actually put anything into the middle, that warning would basically fire for 100% of the code</p>



<a name="172239391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239391">(Aug 01 2019 at 17:04)</a>:</h4>
<p>(like, any code using <code>align_to</code> on a sufficiently big slice)</p>



<a name="172239420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239420">(Aug 01 2019 at 17:04)</a>:</h4>
<p>so we might as well not have the warning and just generally encourage using different seeds</p>



<a name="172239431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172239431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172239431">(Aug 01 2019 at 17:04)</a>:</h4>
<p>and maybe that's indeed the best we can do</p>



<a name="172240781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172240781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172240781">(Aug 01 2019 at 17:20)</a>:</h4>
<p>ah btw, if we ever want to make <code>align_to</code> a <code>const fn</code> we also have to keep its spec the way it is.</p>



<a name="172248445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172248445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172248445">(Aug 01 2019 at 18:41)</a>:</h4>
<p><code>align_to</code> was made specifically with the intention that <code>miri</code> would never put anything in the middle.</p>



<a name="172248466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172248466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172248466">(Aug 01 2019 at 18:41)</a>:</h4>
<p>well, would be allowed to not.</p>



<a name="172253918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172253918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172253918">(Aug 01 2019 at 19:39)</a>:</h4>
<p>Note that miri the tool may still use the nondeterministic mode to arbitrarily overalign for fuzzing reasons</p>



<a name="172253974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172253974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172253974">(Aug 01 2019 at 19:40)</a>:</h4>
<p>Const eval needs to do the deterministic non-aligning</p>



<a name="172254052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172254052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172254052">(Aug 01 2019 at 19:41)</a>:</h4>
<p>There's also no point in using <code>ptr::align</code> because it also does the fallback where it returns usize::max_value or sth</p>



<a name="172260953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172260953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172260953">(Aug 01 2019 at 20:58)</a>:</h4>
<p>we <em>could</em> decide to change the spec of <code>align_to</code> and the underlying <code>align</code> to disallow spurious failures when run outside const context. that would be implementable at least. it would however restrict miri's ability to do alignment checks. I would be fine if t-libs concluded that this trade-off is worth it.</p>



<a name="172269525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172269525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172269525">(Aug 01 2019 at 23:11)</a>:</h4>
<p>What’s the point though? The whole point of this function is that you would have to write code that has no observable differences (other than performance) regardless of how inputs are split</p>



<a name="172274128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172274128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172274128">(Aug 02 2019 at 00:43)</a>:</h4>
<p>I've written code (nothing outside of throwaway demos, thankfully) that assumed that using align_to to go from &amp;[u8] to &amp;[T] wouldn't return more than align_of::&lt;T&gt;() items in the first slice. I think I just asserted on this, but hearing that miri takes advantage of this to put everything in the first slice is fairly surprising</p>



<a name="172286211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172286211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172286211">(Aug 02 2019 at 06:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> Ah, finally found the rustc issue for this: <a href="https://github.com/rust-lang/rust/issues/62420" target="_blank" title="https://github.com/rust-lang/rust/issues/62420">https://github.com/rust-lang/rust/issues/62420</a></p>



<a name="172286225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172286225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172286225">(Aug 02 2019 at 06:06)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> given that we explicitly document that code may not rely on getting the best possible splitting, is there anything else that could be done to make this less surprising?</p>



<a name="172286532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172286532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172286532">(Aug 02 2019 at 06:14)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> Err, why can't it always return slices such that the middle is the largest possible? I agree it's documented, but it seems like a needless restriction that will only trip people up.</p>



<a name="172286696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172286696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172286696">(Aug 02 2019 at 06:18)</a>:</h4>
<p>I'm probably missing something though, since I've mostly thought about this for the &amp;[u8] input case</p>



<a name="172287772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172287772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172287772">(Aug 02 2019 at 06:46)</a>:</h4>
<p>The reason this exists is that const eval cannot return a middle slice because it doesn't know the alignment of an allocation</p>



<a name="172287776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172287776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172287776">(Aug 02 2019 at 06:46)</a>:</h4>
<p>Like the real alignment</p>



<a name="172287812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172287812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172287812">(Aug 02 2019 at 06:48)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> returning anything is for miri to be able to check the code that <em>should</em> be the same, but the user may have screwed up</p>



<a name="172288244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288244">(Aug 02 2019 at 06:58)</a>:</h4>
<p>We don't tend to put needless restrictions into our language spec. We are not the adversary. ;)</p>



<a name="172288249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288249">(Aug 02 2019 at 06:58)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> <a href="https://github.com/rust-lang/rust/issues/62420" target="_blank" title="https://github.com/rust-lang/rust/issues/62420">https://github.com/rust-lang/rust/issues/62420</a> mentions some reasons</p>



<a name="172288347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288347">(Aug 02 2019 at 07:00)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> hm, I just realized that with dropping alignment checks from CTFE, the argument that we need this to make <code>align_to</code> a <code>const fn</code> becomes much weaker</p>



<a name="172288365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288365">(Aug 02 2019 at 07:01)</a>:</h4>
<p>OTOH, we still don't have an alignment to actually use</p>



<a name="172288518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288518">(Aug 02 2019 at 07:04)</a>:</h4>
<p>Yeah I think CTFE is a strong argument here.<br>
<span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> so imagine running this during CTFE. When the program wants a 1-aligned allocation, such as for <code>Vec&lt;u8&gt;</code>, we create an allocation that we remember to have alignment 1. We don't actually position this anywhere in the virtual address space -- after all we cannot know (in case this allocation end up in the output of CTFE and is used by the final program) where in the virtual address space this allocation will lie. So even for a 1-aligned allocation of size 256, where in the final program there will be <em>some</em> 8-aligned indices in that allocation, we cannot know <em>which</em> are 8-aligned during CTFE. So conservatively, we have to treat none of them as 8-aligned.</p>



<a name="172288546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288546">(Aug 02 2019 at 07:05)</a>:</h4>
<p>However, in <span class="user-mention" data-user-id="116155">@Jake Goulding</span>'s original test case here, the allocation actually <em>is</em> 8-aligned. So we could do better here.</p>



<a name="172288598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172288598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172288598">(Aug 02 2019 at 07:06)</a>:</h4>
<p>I am still not convinced that <code>align_to</code> actually helps for what <span class="user-mention" data-user-id="116155">@Jake Goulding</span> wants to achieve, but we might be able to get one obstacle out of the way.</p>



<a name="172289428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172289428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172289428">(Aug 02 2019 at 07:25)</a>:</h4>
<p>Oh, that makes sense. We can make <code>align_to</code> respect the allocation's alignment. I think we even have a FIXME for that somewhere</p>



<a name="172289437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172289437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172289437">(Aug 02 2019 at 07:25)</a>:</h4>
<p>we do</p>



<a name="172289443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172289443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172289443">(Aug 02 2019 at 07:25)</a>:</h4>
<p>this is not easy in general though</p>



<a name="172289487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172289487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172289487">(Aug 02 2019 at 07:26)</a>:</h4>
<p>hm well maybe it's not so bad</p>



<a name="172289491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172289491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172289491">(Aug 02 2019 at 07:26)</a>:</h4>
<p>if requested alignment is &lt;= alloc.align:  round up offset to next multiple of requested align</p>



<a name="172289492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172289492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172289492">(Aug 02 2019 at 07:26)</a>:</h4>
<p>does that seem reasonable?</p>



<a name="172290155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172290155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172290155">(Aug 02 2019 at 07:41)</a>:</h4>
<p>Jup, or offset by zero if already aligned</p>



<a name="172290464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172290464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172290464">(Aug 02 2019 at 07:47)</a>:</h4>
<p>that should be an instance of "round up to next multiple"</p>



<a name="172290479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172290479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172290479">(Aug 02 2019 at 07:48)</a>:</h4>
<p>the one thing I am worried about here is that the code iterating over the middle part (if non-empty) might use SSE or so...^^</p>



<a name="172290903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172290903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172290903">(Aug 02 2019 at 07:56)</a>:</h4>
<p>ah it gets more complicated becuase <code>align_offset</code> returns an offset it units of <code>size_of::&lt;T&gt;()</code></p>



<a name="172290910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172290910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172290910">(Aug 02 2019 at 07:56)</a>:</h4>
<p>so the best thing probably is to just run the libcore code...^^</p>



<a name="172290998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172290998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172290998">(Aug 02 2019 at 07:58)</a>:</h4>
<p>see <a href="https://github.com/rust-lang/miri/issues/873" target="_blank" title="https://github.com/rust-lang/miri/issues/873">https://github.com/rust-lang/miri/issues/873</a></p>



<a name="172292724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292724">(Aug 02 2019 at 08:33)</a>:</h4>
<p>Oh right</p>



<a name="172292733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292733">(Aug 02 2019 at 08:33)</a>:</h4>
<p>OK, we are doing the right thing here</p>



<a name="172292792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292792">(Aug 02 2019 at 08:34)</a>:</h4>
<p>We can't detect SSE vs non-sse</p>



<a name="172292796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292796">(Aug 02 2019 at 08:34)</a>:</h4>
<p>Or lol, we can</p>



<a name="172292836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292836">(Aug 02 2019 at 08:35)</a>:</h4>
<p>Make a snapshot, wait for failure, if it happens, revert and run normally</p>



<a name="172292850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292850">(Aug 02 2019 at 08:35)</a>:</h4>
<p>Kill snapshot on return from frame that did snapshot</p>



<a name="172292902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172292902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172292902">(Aug 02 2019 at 08:36)</a>:</h4>
<p><span aria-label="smiling devil" class="emoji emoji-1f608" role="img" title="smiling devil">:smiling_devil:</span></p>



<a name="172294553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172294553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172294553">(Aug 02 2019 at 09:12)</a>:</h4>
<p><span aria-label="skull" class="emoji emoji-1f480" role="img" title="skull">:skull:</span></p>



<a name="172294569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172294569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172294569">(Aug 02 2019 at 09:12)</a>:</h4>
<p>maybe they are not using complex SSE instructions ;) from what I gathered, there's a small amount of them that should cover most code</p>



<a name="172338095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172338095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172338095">(Aug 02 2019 at 20:00)</a>:</h4>
<blockquote>
<p>We don't tend to put needless restrictions into our language spec. We are not the adversary. ;)</p>
</blockquote>
<p>Sure, but it's often in a language designer's best interest to be vague where possible, whereas it's in the programmer's best interest for those vagueness's to be concrete.</p>



<a name="172338849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Does%20Miri%20support%20%60repr%28align%29%60%3F/near/172338849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Does.20Miri.20support.20.60repr(align).60.3F.html#172338849">(Aug 02 2019 at 20:12)</a>:</h4>
<p>I like proving things about programs, so I don't usually like vague. ;)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>